﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using System.Runtime.InteropServices;

namespace System.IO
{
    /// <summary>
    /// 文件操作
    /// </summary>
    public class IOProess
    {
        /// <summary>
        /// File exists
        /// </summary>
        /// <param name="filename">file name</param>
        /// <returns>scuess</returns>
        public static bool FileExists(string filename)
        {
            return System.IO.File.Exists(filename);
        }

        /// <summary>
        /// Create Directory
        /// </summary>
        /// <param name="name">Directory Path</param>
        /// <returns>Directory Info</returns>
        public static DirectoryInfo CreateDir(string name)
        {
            return Directory.CreateDirectory(name);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sourceFileName"></param>
        /// <param name="destFileName"></param>
        /// <param name="overwrite"></param>
        /// <returns></returns>
        public static bool CopyFile(string sourceFileName, string destFileName)
        {
            if (!FileExists(sourceFileName))
                throw new FileNotFoundException();

            System.IO.File.Copy(sourceFileName, destFileName, true);

            return true;
        }

        /// <summary>
        /// Extension Name
        /// </summary>
        /// <param name="fileName">Filename</param>
        /// <returns>Extension</returns>
        public static string GetFileExtName(string fileName)
        {
            return Path.GetExtension(fileName);
        }

        /// <summary>
        /// Delete File
        /// </summary>
        /// <param name="file">File Name</param>
        /// <returns></returns>
        public static bool Del(string filename)
        {
            System.IO.File.Delete(filename);
            return true;
        }
    }
}
